# -*- coding = utf-8 -*-
# Author：凌杰
# Email：577709198@qq.com

from PIL import Image


def imgSize(infile, outfile):
    outfile = outfile
    im = Image.open(infile)
    (x, y) = im.size  # read image size

    x_s = 800  # define standard width
    y_s = int(y * x_s / x)  # calc height based on standard width
    if x >= 1000:
        out = im.resize((x_s, y_s), Image.ANTIALIAS)  # resize image with high-quality
        out.save(outfile)
    # print('original size: ', x, y)
    # print('adjust size: ', x_s, y_s)


if __name__ == '__main__':
    imgSize('aaa.jpg', 'aaa.jpg')

